package com.bingo.demo.service;

import com.bingo.demo.DAO.UserMapper;
import com.bingo.demo.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {

    @Autowired
    UserMapper userMapper;

    public User findUserByUsername(String username){
        return userMapper.findUserByUsername(username);
    }

    public User findUserById(Integer id){
        return userMapper.findUserById(id);
    }

    public void addUser(User user){
        //生成随机用户ID
        String number=Integer.toString((int)(Math.random()*100000000));
        user.setNumber(number);
        userMapper.addUser(user);
    }

    public void updateUser(User user){
        userMapper.updateUser(user);
    }
}
